﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RN.ERP.Web.BasicService;

namespace RN.ERP.Web.UserControl
{
    public partial class UCCityArea : System.Web.UI.UserControl
    {
        private string _setArea;
        //public string SetArea
        //{
        //    set
        //    {
        //        _setArea = value;
        //    }
        //}

        //public string SelectedArea
        //{
        //    get
        //    {
        //        return hidCode.Value;
        //    }
        //}

        /// <summary>
        /// 获取或设置控件的地区编号。
        /// </summary>
        public string AreaCode
        {
            get
            {
                return hidCode.Value;
            }
            set
            {
                _setArea = value;
            }
        }
        /// <summary>
        /// 只显示省内各市
        /// </summary>
        public string OnlyContainsProvinceCity
        {
            get;
            set;
        }
        /// <summary>
        /// 是否排除已有的市场范围
        /// </summary>
        public string IsRemoveExistEmbranchArea
        {
            get;
            set;
        }
        /// <summary>
        /// 排除的地区集合，满足某些地区因为使用单独的数据库，故在该系统中不将这些地区作为市场范围
        /// 如青岛、潍坊
        /// 格式使用,分隔
        /// </summary>
        public string ExceptAreas { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(_setArea))
                {
                    hidCode.Value = _setArea;
                    BasicServiceClient client = new BasicServiceClient();
                    lblAdress.Text = client.GetAddress(hidCode.Value);
                }
                if (!string.IsNullOrEmpty(OnlyContainsProvinceCity))
                {
                    hidOnlyContainsProvinceCity.Value = OnlyContainsProvinceCity.ToLower()=="true"?"1":"0";
                }
                if (!string.IsNullOrEmpty(IsRemoveExistEmbranchArea))
                {
                    hidIsRemoveExistEmbranchArea.Value = IsRemoveExistEmbranchArea.ToLower() == "true" ? "1" : "0";
                }
                if (!string.IsNullOrEmpty(ExceptAreas))
                {
                    hidExceptAreas.Value = ExceptAreas;
                }
            }
        }
    }
}